// 底部弹出框的内容
import 'package:flutter/material.dart';
import 'package:get/get.dart';

Widget buildBottomSheetWidget({List itemList = const [], Function? onSelect}) {
  // var screenBottomHeight =
  //     double.parse(GlobalPrefs.getValue("screenBottomHeight"));

  // var screenBottomHeight = Get.overlayContext!.mediaQuery.padding.bottom;

  var screenBottomHeight = MediaQuery.of(Get.context!).padding.bottom;
  // var screenBottomHeight = MediaQuery.of(Get.overlayContext!).padding.bottom;
  double h = itemList.length * 55;
  return Container(
      height: 60 + screenBottomHeight + h + 10,
      padding: const EdgeInsets.only(left: 10, right: 10),
      decoration: const BoxDecoration(
        color: Colors.transparent,
      ),
      child: Column(
        children: [
          Container(
            width: double.infinity,
            decoration: const BoxDecoration(
              color: Color.fromARGB(200, 255, 255, 255),
              borderRadius: BorderRadius.all(Radius.circular(15.0)),
            ),
            height: h,
            child: Column(
              children: [
                ...itemList.asMap().keys.map((index) {
                  return GestureDetector(
                    onTap: () {
                      Get.back();
                      if (itemList[index]["onClick"] != null) {
                        itemList[index]["onClick"]();
                      }
                      // if (onSelect != null) {
                      //   onSelect("Camera");
                      // }
                    },
                    child: Container(
                      width: double.infinity,
                      alignment: Alignment.center,
                      height: 55,
                      decoration: const BoxDecoration(
                        border: Border(
                            bottom: BorderSide(
                                width: 1.0, color: Color(0xffb8b8b8))),
                      ),
                      // color: Colors.red,
                      child: Text(
                        itemList[index]["label"].toString(),
                        style: const TextStyle(
                            fontSize: 18,
                            color: Color(0xff4578e5),
                            fontWeight: FontWeight.w500),
                      ),
                    ),
                  );
                }).toList(),
                // GestureDetector(
                //   onTap: () {
                //     Get.back();
                //     if (onSelect != null) {
                //       onSelect("Camera");
                //     }
                //   },
                //   child: Container(
                //     width: double.infinity,
                //     alignment: Alignment.center,
                //     height: 55,
                //     decoration: const BoxDecoration(
                //       border: Border(
                //           bottom:
                //               BorderSide(width: 1.0, color: Color(0xffb8b8b8))),
                //     ),
                //     // color: Colors.red,
                //     child: const Text(
                //       "拍照",
                //       style: TextStyle(
                //           fontSize: 18,
                //           color: Color(0xff4578e5),
                //           fontWeight: FontWeight.w500),
                //     ),
                //   ),
                // ),
                // GestureDetector(
                //   onTap: () {
                //     Get.back();
                //     if (onSelect != null) {
                //       onSelect("Gallery");
                //     }
                //   },
                //   child: Container(
                //     width: double.infinity,
                //     alignment: Alignment.center,
                //     height: 55,
                //     decoration: const BoxDecoration(),
                //     // co
                //     // color: Colors.red,
                //     child: const Text("我的相册",
                //         style: TextStyle(
                //           fontSize: 18,
                //           fontWeight: FontWeight.w500,
                //           color: Color(0xff4578e5),
                //         )),
                //   ),
                // ),
              ],
            ),
          ),
          const SizedBox(
            height: 10,
          ),
          GestureDetector(
              onTap: () {
                Get.back();
              },
              child: Container(
                width: double.infinity,
                alignment: Alignment.center,
                decoration: const BoxDecoration(
                  color: Color.fromARGB(200, 255, 255, 255),
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(15.0),
                      topRight: Radius.circular(15.0),
                      bottomLeft: Radius.circular(15.0),
                      bottomRight: Radius.circular(15.0)),
                ),
                // co
                height: 55,
                child: const Text(
                  "取消",
                  style: TextStyle(
                      fontSize: 18,
                      color: Color(0xff4578e5),
                      fontWeight: FontWeight.w500),
                ),
              ))
        ],
      ));
}
